<?php
set_time_limit(0);

include "Crocodile/Upload.php";
include "Crocodile/Signature.php";
include "Crocodile/File.php";
include "Crocodile/Util/MultiPartPost.php";

use Crocodile\Signature;
use Crocodile\Upload;

$file = 'sql_'.date('Ymd').'.zip';
$filename = '/home/backup/'.$file;

//$file = 'SourceTreeSetup_1.8.3.exe';
//$filename = '/Users/mtzjb0136/Downloads/'.$file;

$upfile = '/uploads/'.$file;

if(!file_exists($filename)) {
    echo $filename . " doesn''t exists \n";
    exit;
}

$formApiKey = "W07yHA7SXSOns/PABdPdvBQ9NNk=";
$sign = new Signature($formApiKey);
$upload = new Upload($sign);
$upload->setBucketName('lnpan');//上传的空间
$upload->printBlockResult();

var_dump($filename);
try {
    //其他参数参见文档: http://docs.upyun.com/api/form_api/#Policy内容详解
    $options = array(
       'path' => $upfile,
    );
    print_r($options);

    $result = $upload->upload(
        new \Crocodile\File($filename),
        $options
    );

    print_r($result);

} catch(\Exception $e) {
    echo $e->getMessage();
}



